package cn.edu.neusoft.yuejian4.yuejian_4.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;


import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

import cn.edu.neusoft.yuejian4.yuejian_4.Config.Server;
import cn.edu.neusoft.yuejian4.yuejian_4.R;
import cn.edu.neusoft.yuejian4.yuejian_4.activity.ShowDetailsActivity;
import cn.edu.neusoft.yuejian4.yuejian_4.javaBean.ShowUnitPic;
import cn.edu.neusoft.yuejian4.yuejian_4.javaBean.Slideshow;

/**
 * Created by Lix on 2018/10/15.
 */

public class ShowDetailsAllPicAdapter extends RecyclerView.Adapter<ShowDetailsAllPicAdapter.ViewHolder>  {

    private ArrayList<ShowUnitPic> mSlideshow;
    private Context mContext;

    public ShowDetailsAllPicAdapter(Context mContext, ArrayList<ShowUnitPic> mSlideshow){
        this.mContext = mContext;
        this.mSlideshow = mSlideshow;
        //mLayoutInflater = LayoutInflater.from(mContext);
    }


    @Override
    public ShowDetailsAllPicAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.show_allpic_cardview,parent,false);
        ShowDetailsAllPicAdapter.ViewHolder holder = new ShowDetailsAllPicAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ShowDetailsAllPicAdapter.ViewHolder holder, int position) {

        final ShowUnitPic showUnitPic = mSlideshow.get(position);
        //String showAllPic = showUnitPic.getPic();
        //String[] Str1Array = showAllPic.split("#");//结果Str1Array：[**.jpg, **.jpg, **.jpg]

           Picasso.with(mContext)
                   .load(Server.PIC_URL_J+showUnitPic.getPic())
                   .placeholder(R.drawable.ic_default_img)
                   .memoryPolicy(MemoryPolicy.NO_CACHE)
                   .into(holder.img);
    }



    @Override
    public int getItemCount() {
        return mSlideshow.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        ImageView img;


        public ViewHolder(View view){
            super(view);
            img= (ImageView)view.findViewById(R.id.show_details_unitpic);

        }
    }
}
